package com.zsc.edu.testcustomizeui;

import android.content.Context;
import android.util.AttributeSet;
import android.widget.LinearLayout;
import android.widget.TextView;

import androidx.annotation.Nullable;


class MyView extends LinearLayout {

    TextView text_view = null;

    // 一定要实现 attrs 的构造函数，否则 MyView 在 layout 中 setContentView 时 inflate 会出错
    public MyView(Context context, @Nullable  AttributeSet attrs) {
        super(context, attrs);

        inflate(context,R.layout.view_nest,this);

        text_view = findViewById(R.id.text_view);
    }

    public void setToast(String msg){
        if (text_view != null){
            text_view.setText(msg);
        }
    }
}
